/**
 * API接口封装
 */
import http from '@/common/utils/request.js';

// 菜单相关接口
export const menuApi = {
  // 获取菜品分类列表
  getCategoryList: () => http.get('/category/list'),
  
  // 获取菜品列表
  getDishList: (params) => http.get('/dish/list', params),
  
  // 获取菜品详情
  getDishDetail: (id) => http.get(`/dish/detail/${id}`),
  
  // 搜索菜品
  searchDish: (keyword) => http.get('/dish/search', { keyword })
};

// 购物车相关接口
export const cartApi = {
  // 获取购物车列表
  getCartList: () => http.get('/cart/list'),
  
  // 添加到购物车
  addToCart: (data) => http.post('/cart/add', data),
  
  // 更新购物车商品数量
  updateCartItem: (data) => http.put('/cart/update', data),
  
  // 删除购物车商品
  removeCartItem: (id) => http.delete(`/cart/remove/${id}`),
  
  // 清空购物车
  clearCart: () => http.delete('/cart/clear')
};

// 订单相关接口
export const orderApi = {
  // 创建订单
  createOrder: (data) => http.post('/order/create', data),
  
  // 获取订单列表
  getOrderList: (params) => http.get('/order/list', params),
  
  // 获取订单详情
  getOrderDetail: (id) => http.get(`/order/detail/${id}`),
  
  // 取消订单
  cancelOrder: (id) => http.put(`/order/cancel/${id}`),
  
  // 支付订单
  payOrder: (data) => http.post('/order/pay', data)
};

// 支付相关接口
export const payApi = {
  // 获取微信支付参数
  getWxPayParams: (orderId) => http.post('/pay/wx-pay', { orderId }),
  
  // 查询支付状态
  checkPayStatus: (orderId) => http.get(`/pay/status/${orderId}`)
};

// 餐桌相关接口
export const tableApi = {
  // 扫码获取餐桌信息
  getTableInfo: (tableId) => http.get(`/table/info/${tableId}`)
};

// 用户相关接口
export const userApi = {
  // 用户登录
  login: (data) => http.post('/user/login', data),
  
  // 获取用户信息
  getUserInfo: () => http.get('/user/info')
}; 